class Solution(object):
    def numberOfArrays(self, s, k):
        n = len(s)
        base = 10 ** 9 + 7
        wei = len(str(k))
        DP = [0] * n
        for i in range(n):
            for j in range(max(0, i - wei + 1), i + 1):
                if s[j] != '0' and int(s[j: i + 1]) <= k:
                    if j == 0:
                        DP[i] = (DP[i] + 1) % base
                    else:
                        DP[i] = (DP[i] + DP[j - 1]) % base

        return DP[-1]





data = Solution()
s = "2020"
k = 30
print(data.numberOfArrays(s, k))